package com.xli.dto.component.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.xli.dto.component.view.View;

import java.io.IOException;

public class ModelSerializer extends JsonSerializer<View> {

    @Override
    public void serialize(View view, JsonGenerator gen, SerializerProvider provider) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        gen.writeTree(mapper.readTree(view.toString()));
    }
}
